#include <string>

// for c
#include <cutils/properties.h>
#define LOG_TAG "prop_test"
#include <log/log.h>

#include <android-base/properties.h>

// for adb
#define ADBD_TCP_DEFAULT_PORT  15000
#define PROP_ADBD_TCP_PORT "service.adb.tcp.port"

using   namespace  std;

void print_android_version()
{
    char android_version[PROPERTY_VALUE_MAX];
    property_get("ro.build.version.release", android_version, "");

    ALOGD("android version : %s", android_version);

}

void  set_adbd_tcp_port(unsigned int port){
    if(port <= 10000)
        port = ADBD_TCP_DEFAULT_PORT;
    property_set(PROP_ADBD_TCP_PORT, std::to_string(port).c_str());


}

void CplusTestPropString()
{

    const char* test_props[] = {
        "ro.product.name",
        "ro.product.model",
        "ro.product.device",
    };

    for (const auto& prop : test_props) {
        std::string value = std::string(prop) + "=" + android::base::GetProperty(prop, "");
    ALOGD("CPlUS API--%s", value.c_str());
    }

}



int main(int argc, char *argv[])
{
    print_android_version();
    CplusTestPropString();

    property_set("vendor.new.prop.test.name", "qh100");

#if 0
    set_adbd_tcp_port(0);
    property_set("ctl.stop", "adbd");
    property_set("ctl.start", "adbd");
#else
    property_set("ctl.restart", "vendor.gnss_service");
#endif

    while(1);

    return 0;
}
                                                                                                                                                                                                                                                 1,1          顶端

